package com.changanw.tienchin.web.controller.tienchin;


import com.changanw.tienchin.common.core.domain.AjaxResult;
import com.changanw.tienchin.follow.service.IFollowRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author changanw
 * @since 2023-11-25
 */
@RestController
@RequestMapping("/tienchin/follow/record")
public class FollowRecordController {

  @Autowired
  IFollowRecordService followRecordService;

  @PreAuthorize("hasAnyPermissions('tienchin:clue:follow','tienchin:clue:view')")
  @GetMapping("/clue/{clueId}")
  public AjaxResult getRecordByClueId(@PathVariable Integer clueId){
    return followRecordService.getRecordByClueId(clueId);
  }

  /**
   * 根据商机id 获取商机跟进记录
   * @param clueId
   * @return
   */
  @PreAuthorize("hasAnyPermissions('tienchin:business:follow','tienchin:business:view')")
  @GetMapping("/business/{businessId}")
  public AjaxResult getRecordByBusinessId(@PathVariable Integer businessId){
    return followRecordService.getRecordByBusinessId(businessId);
  }
}
